#include "Stack.h"



bool isValid(char* s) {
    int i = 0;
    if (s[i] == ')' || s[i] == '}' || s[i] == ']')
    {
        return false;
    }
    ST st;
    STInit(&st);
    while (s[i])
    {
        if (s[i] == '(' || s[i] == '{' || s[i] == '[')
        {
            STPush(&st, s[i]);
        }
        if (s[i] == ')' || s[i] == '}' || s[i] == ']')
        {
            if (st.top == 0)
            {
                STDestroy(&st);
                return false;
            }
            char a = STTop(&st);
            STPop(&st);
            if ((a == '(' && s[i] != ')')
                || (a == '{' && s[i] != '}')
                || (a == '[' && s[i] != ']'))
            {
                STDestroy(&st);
                return false;
            }
        }
        i++;
    }

    if (!STEmpty(&st))
    {
        STDestroy(&st);
        return false;
    }
    STDestroy(&st);
    return true;

}




int main()
{

    char s[] = "[[[[[[[[[[[[[[[[[[[";
    printf("%s", s);
    if (isValid(s))
    {
        printf("1");
    }

    return 0;
}

